home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / magict_1 / udp1.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-08-09  |  5.1 KB  |  182 lines

  1. VERSION 5.00
  2. Object = "{3035B5D2-295D-11D3-8C54-006008BA8D16}#1.0#0"; "MAGICTCP.OCX"
  3. Begin VB.Form Form1 
  4.    Caption         =   "Form1"
  5.    ClientHeight    =   6150
  6.    ClientLeft      =   60
  7.    ClientTop       =   345
  8.    ClientWidth     =   8475
  9.    LinkTopic       =   "Form1"
  10.    ScaleHeight     =   6150
  11.    ScaleWidth      =   8475
  12.    StartUpPosition =   3  'Windows-Standard
  13.    Begin VB.TextBox txtLocalPort 
  14.       Height          =   285
  15.       Left            =   1200
  16.       TabIndex        =   7
  17.       Top             =   720
  18.       Width           =   735
  19.    End
  20.    Begin VB.TextBox txtOutput 
  21.       Height          =   4095
  22.       Left            =   120
  23.       MultiLine       =   -1  'True
  24.       ScrollBars      =   3  'Beides
  25.       TabIndex        =   0
  26.       TabStop         =   0   'False
  27.       Top             =   1920
  28.       Width           =   8295
  29.    End
  30.    Begin VB.TextBox txtInput 
  31.       Height          =   285
  32.       Left            =   1200
  33.       TabIndex        =   1
  34.       Top             =   1200
  35.       Width           =   7215
  36.    End
  37.    Begin VB.TextBox txtPort 
  38.       Height          =   285
  39.       Left            =   5400
  40.       TabIndex        =   3
  41.       Text            =   "5555"
  42.       Top             =   240
  43.       Width           =   735
  44.    End
  45.    Begin VB.TextBox txtHost 
  46.       Height          =   285
  47.       Left            =   1200
  48.       TabIndex        =   2
  49.       Text            =   "localhost"
  50.       Top             =   240
  51.       Width           =   2655
  52.    End
  53.    Begin VB.Label Label5 
  54.       Caption         =   "Received Text"
  55.       Height          =   255
  56.       Left            =   120
  57.       TabIndex        =   9
  58.       Top             =   1680
  59.       Width           =   1455
  60.    End
  61.    Begin VB.Label Label4 
  62.       Caption         =   "Send Text"
  63.       Height          =   255
  64.       Left            =   120
  65.       TabIndex        =   8
  66.       Top             =   1200
  67.       Width           =   855
  68.    End
  69.    Begin VB.Label Label3 
  70.       Caption         =   "Local Port"
  71.       Height          =   255
  72.       Left            =   120
  73.       TabIndex        =   6
  74.       Top             =   720
  75.       Width           =   855
  76.    End
  77.    Begin VB.Label Label2 
  78.       Caption         =   "Remote Port"
  79.       Height          =   255
  80.       Left            =   4320
  81.       TabIndex        =   5
  82.       Top             =   240
  83.       Width           =   975
  84.    End
  85.    Begin VB.Label Label1 
  86.       Caption         =   "Remote Host"
  87.       Height          =   255
  88.       Left            =   120
  89.       TabIndex        =   4
  90.       Tag             =   "Re"
  91.       Top             =   240
  92.       Width           =   975
  93.    End
  94.    Begin M3LibCtl.MagicTCP M1 
  95.       Left            =   6960
  96.       OleObjectBlob   =   "UDP1.frx":0000
  97.       Top             =   120
  98.    End
  99.    Begin VB.Line Line1 
  100.       X1              =   120
  101.       X2              =   8400
  102.       Y1              =   1080
  103.       Y2              =   1080
  104.    End
  105. Attribute VB_Name = "Form1"
  106. Attribute VB_GlobalNameSpace = False
  107. Attribute VB_Creatable = False
  108. Attribute VB_PredeclaredId = True
  109. Attribute VB_Exposed = False
  110. Option Explicit
  111. Const K_SECTION = "UPDCHAT"
  112. Const K_REMOTEHOST = "REMOTEHOST"
  113. Const K_REMOTEPORT = "REMOTEPORT"
  114. Const K_LOCALPORT = "LOCALPORT"
  115. Private Sub Text2_Change()
  116. End Sub
  117. Private Sub Form_Load()
  118. With M1
  119.     .Type = 2       ' UDP
  120.     txtHost = .GetProfileString(K_SECTION, K_REMOTEHOST, "192.168.1.11")
  121.     txtPort = CStr(.GetProfileInt(K_SECTION, K_REMOTEPORT, 3333))
  122.     txtLocalPort = CStr(.GetProfileInt(K_SECTION, K_LOCALPORT, 3333))
  123.     .RemoteHost = txtHost
  124.     .RemotePort = txtPort
  125.     .LocalPort = CLng(txtLocalPort)
  126.     If Not .Bind Then
  127.         MsgBox "BIND-Error: " & .LastErrorText
  128.         End
  129.     End If
  130. End With
  131. End Sub
  132. Private Sub m1_OnRead()
  133. Dim s As String
  134. With M1
  135.     If .ReadString(s) Then
  136.         txtOutput = txtOutput & .FromHost & ":" & .FromPort & " " & s & vbCrLf
  137.     Else
  138.         MsgBox "Read-Error: " & .LastErrorText
  139.     End If
  140. End With
  141. End Sub
  142. Private Sub txtHost_LostFocus()
  143. With M1
  144.     .RemoteHost = LCase$(Trim$(txtHost))
  145.     .SetProfileString K_SECTION, K_REMOTEHOST, .RemoteHost
  146. End With
  147. End Sub
  148. Private Sub txtInput_KeyPress(KeyAscii As Integer)
  149. If KeyAscii = 13 Then
  150.     With M1
  151.         If .WriteString(txtInput) < Len(txtInput) Then
  152.             MsgBox "Write-Error: " & .LastErrorText
  153.         Else
  154.             txtInput = ""
  155.         End If
  156.     End With
  157. End If
  158. End Sub
  159. Private Sub txtLocalPort_LostFocus()
  160. Dim p As Long
  161. With M1
  162.     p = CLng(Trim$(txtLocalPort))
  163.     If p <> .LocalPort Then
  164.         .Close
  165.         
  166.         .Type = 2       ' UDP
  167.         .LocalPort = p
  168.         If .Bind Then
  169.             .SetProfileInt K_SECTION, K_REMOTEPORT, p
  170.         Else
  171.             MsgBox "Bind-Error: " & .LastErrorText
  172.         End If
  173.     End If
  174. End With
  175. End Sub
  176. Private Sub txtPort_LostFocus()
  177. With M1
  178.     .RemotePort = CLng(Trim$(txtPort))
  179.     .SetProfileInt K_SECTION, K_REMOTEPORT, .RemotePort
  180. End With
  181. End Sub
  182.